/*
 * @Author: zhengchao
 * @Date: 2021-09-27 17:21:37
 * @LastEditors: zhengchao
 * @LastEditTime: 2021-12-28 17:26:07
 * @Description:  
 * @FilePath: \nocode-react-ts\src\components\middle\dynamicEngine.jsx
 */
import { useEffect, useState, lazy, Suspense, memo } from 'react';

const DynamicEngine = memo((props) => {
  const [Comp, setComp] = useState("div")
  
  useEffect(() => {
    (async () => {
      setComp(
        lazy(() => import(/* webpackMode: "eager" */ `../boxs/${props.classify}/${props.id}/${props.id}.tsx`))
      )
    })()
  }, [props])
  
  return <Suspense fallback={<div></div>}>
    <Comp {...props} />
  </Suspense>
})

export default DynamicEngine

